package com.fce.fcesystem.service;

import com.fce.fcesystem.pojo.Menu;
import com.fce.fcesystem.pojo.Role;
import com.fce.fcesystem.pojo.RoleMenu;
import com.fce.fcesystem.pojo.User;
import com.fce.fcesystem.utils.JsonResult;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

public interface IUserService {

    void register(User user);

    JsonResult<String[]> login(String account, String password, HttpServletRequest httpServletRequest);

    void updateUserPassword(Integer id, String oldPassword, String newPassword);

    List<User> getAdmins(String name);

    List<User> selectUsers(String name);

    User selectUserByAccount(String account);

    User selectUserById(Integer userId);

    void deleteUser(Integer userId);

    void deleteUserRole(Integer userId,Integer roleId);

    String updateHref(MultipartFile file, String userName) throws IOException;

    void updateUser(Integer userId,Integer oldRoleId, Integer newRoleId);

    void updateUserInfo(Integer userId, String userName, String email,String phone);

    void emailLoad(String key, String userName);

    void updatePwdByKey(String userName, String email, String key, String password);

    /**
     * 根据用户账号查找角色
     * @param account
     * @return
     */
    User findRolesByAccount(String account);

    /**
     * 根据角色id查询权限列表
     * @param id
     * @return
     */
    Role findPermsByRoleId(Integer id);

    User checkUserByPhone(String phone);

    List<Menu> loadMenu(Integer roleId);

    List<Menu> loadChildMenu(Integer parentId,Integer roleId);

    List<RoleMenu> getPermissionList(String roleName);

    void updatePermission(Integer roleId, String roleName,Integer[] menus);

    void deletePermission(Integer roleId);

    void insertPermission(String roleName, Integer[] menus);

    List<Role> getAllRoles();

    List<Menu> getAllMenus();
}
